<%@ page language="java" pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp"%><!DOCTYPE html>
<%
	try {
%>
<html>
<head>
<title>知识库管理--${me.username}</title>
<%@ include file="/common/meta.jsp"%>
<script type="text/javascript"
	src="${ ctx}/scripts/jquery/jquery-1.8.2.min.js"></script>
<script type="text/javascript"
	src="${ ctx}/scripts/jquery/jquery-ui-1.8.24.custom.min.js"></script>
<script type="text/javascript"
	src="${ ctx}/scripts/jquery/jqueryui.bannerize.js"></script>
<script type="text/javascript" src="${ ctx}/scripts/blog.js"></script>

<script type="text/javascript"
	src="${ ctx}/scripts/jquery/jquery.qtip-1.0.0-rc3.js"></script>

<script language="Javascript" src="${ ctx}/scripts/blog.js"
	type="text/javascript"></script>
<link href="${ ctx}/skins/floatstyle.css" rel="stylesheet"
	type="text/css" />
<link href="${ ctx}/skins/showNotice.css" rel="stylesheet"
	type="text/css" />
<link href="${ ctx}/skins/home.css" rel="stylesheet" type="text/css" />
<link href="${ ctx}/skins/picturemodel.css" rel="stylesheet"
	type="text/css" />
<link href="${ctx }/skins/index.css" rel="stylesheet" type="text/css" />
<hql:queryForList
	hql="select distinct title from Article where creatorName='${me.username}' "
	id="allArticle" />
<style type="text/css">
.icon_edit {
	background-image:
		url(images/blog_app_bj.png?max_age=19830211&d=20130226105935);
	background-position: -303px 0;
	float: left;
	margin-right: 5px;
	display: inline-block;
	height: 16px;
	width: 16px;
	background-repeat: no-repeat;
	font-size: 0;
	margin: 3px;
	padding: 0;
}

input.submit {
	background-color: #108AC6;
	border: 1px solid #D2F3FD;
	color: white;
	cursor: pointer;
	font-size: 1em;
	height: 23px;
	padding: 2px 5px;
	vertical-align: middle;
	margin-right: 10px;
}

#blog_preview {
	float: right;
	height: 18px;
	padding: 0 !important;
	text-align: right;
	width: 180px;
}

.blog_main_title {
	border-bottom: 1px dotted;
	margin-bottom: 10px;
	padding: 10px 11px 5px;
}

#fd {
	clear: both;
}

.right {
	float: right;
}

.results {
	border-left: 1px solid #BBBBBB;
	border-right: 1px solid #BBBBBB;
}

.results th,.results_lite th {
	background: none repeat scroll 0 0 #EEEEEE;
	border-bottom: 1px solid #CCCCCC;
	border-top: 1px solid #CCCCCC;
	padding-right: 2px;
	text-align: left;
	border: 1px solid #CCCCCC;
}

.border td {
	border: 1px solid #CCCCCC;
}

.blog_main_title {
	border-bottom: 1px dotted;
	margin-bottom: 10px;
	padding: 10px 11px 5px;
}

.group_row td {
	background: none repeat scroll 0 0 #EBEFF9;
	cursor: pointer;
}

.results td {
	padding: 2px;
	border-bottom: 1px solid #CCCCCC;
}

table td,table th {
	font-size: 12px;
	padding: 6px 10px 6px 0;
	vertical-align: top;
	line-height: 1.5;
}

th,td {
	text-align: left;
	font-weight: normal;
}

.results {
	border-left: 1px solid #BBBBBB;
	border-right: 1px solid #BBBBBB;
}

tr {
	display: table-row;
	border: 1px solid #CCCCCC;
}
</style>

<script type="text/javascript">
	var contextPath = "${ ctx}";
	var userId = "${ me.id}";
	$(function() {
		window.setTimeout("reSetTime()", 10);
		window.setInterval("reSetTime()", 1000 * 10); //时间的更新，每过10s更新一次
		readyBlog();
		var userId = "${me.id}";
	});
	readyBlog();

</script>
</head>
<body id="home-index" class="home-controller not-ie  fixed-header">
	<!--<![endif]-->
	<%@ include file="/common/header.jsp"%>
	<div class='page-content'>

		<!-- 做边框个人信息 -->
		<div id='column-left'><%@ include
				file="/common/left_knowledge_index.jsp"%></div>

		<div id="column-main" style="width: 665px; float: left;">

			<div id="main">

				<div class='blog_main_title'>
					<strong><c:if test="${role=='manager'}">所有知识目录管理</c:if> <c:if
							test="${role=='customer'}">个人知识目录与管理</c:if>
					</strong>
					<div id='fd'></div>
				</div>
				<div id="content-body">
					<c:if test="${role=='manager'}">
						<nativeSql:sqlQueryForList
							sql="select * from t_blog where f_if_personal='1' or f_manager_id = ${me.id}"
							id="blogs" />
					</c:if>
					<c:if test="${role=='customer'}">
						<nativeSql:sqlQueryForList
							sql="select * from t_blog where f_manager_id = ${me.id}"
							id="blogs" />
					</c:if>

					<table cellspacing="0" cellpadding="2" border="0" class="results"
						id="resultstable" width="100%">
						<thead>
							<tr id="headingrow">
								<th style="border-left: 0" nowrap="nowrap">序号</th>
								<th class="col_1" nowrap="nowrap" id="summaryheading"
									width="130px"><a href="#" style="text-decoration: none">博客名称</a>
								</th>
								<th class="col_0" nowrap="nowrap"><a href="#"
									style="text-decoration: none">博客简介</a>
								</th>
								<th class="col_2" nowrap="nowrap"><a href="#"
									style="text-decoration: none">总博文数</a>
								</th>
								<th class="col_3" nowrap="nowrap"><a href="#"
									style="text-decoration: none">我发表的博文 </a>
								</th>
								<th class="col_3" nowrap="nowrap"><a href="#"
									style="text-decoration: none">浏览数</a>
								</th>
								<th class="col_3" nowrap="nowrap"><a href="#"
									style="text-decoration: none">回复数</a>
								</th>
								<th nowrap="nowrap" style="width: 50px;"><a
									href="#columnprefs" style="text-decoration: none">管理</a>
								</th>
							</tr>
						</thead>
						<tbody class="border">

							<c:forEach var="blog" items="${blogs}" varStatus="status">
								<tr class="ifOpened" id="newprojects${blog.f_id }">
									<td class="vt" nowrap="nowrap">${status.index+1 }</td>
									<td class="vt id col_1" width="130px"><a
										href="${ctx }/blog/blog.action?method:blog&blogId=${blog.f_id }">${blog.f_blog_name}</a>
									</td>
									<td class="vt id col_0" nowrap="nowrap"
										title="${blog.blogName}"><a
										href="${ctx }/blog/blog.action?method:blogDescription&blogId=${blog.f_id }">查看</a>
									

									<hql:queryForUnique
										hql="select count(*) from Article where blogId = ${blog.f_id}"
										id="allArticles" />
									<td class="vt id col_2" nowrap="nowrap"><c:if
											test="${empty allArticles}">0</c:if>${allArticles}</td>

									<hql:queryForUnique
										hql="select count(*) from Article where blogId = ${blog.f_id} and creatorName ='${me.username}'"
										id="myArticles" />
									<td class="vt col_3"><c:if test="${empty myArticles}">0</c:if>${myArticles}</td>
									<nativeSql:sqlQueryForUnique
										sql="select sum(f_click) as g from t_article where f_blog_id = ${blog.f_id} and 
									f_creator_name = '${blog.f_manager_name}' and f_click is not null"
										id="gclick" />
									<td class="vt col_3"><c:if test="${empty gclick.g}">0</c:if>${gclick.g}</td>
									<nativeSql:sqlQueryForUnique
										sql="select count(*) as RECNT from t_article_comment where f_article_id in
  										 (select f_id from t_article where f_blog_id = ${blog.f_id} and f_creator_name = '${blog.f_manager_name}')"
										id="replyCount" />

									<td class="vt col_4"><c:if
											test="${empty replyCount['RECNT']}">0</c:if>${replyCount['RECNT']}</td>
									<td class="vt col_3" align="right"><c:if
											test="${blog.f_manager_name==me.username||role=='manager'}">
											<a
												href="${ctx }/blog/blog.action?method:blogEditForm&blogId=${blog.f_id}"
												title="编辑"> <span class="icon_edit"></span>
											</a>
											<a href="javascript://" class="deleteProject${blog.f_id}">
												<img src="${ctx }/img/delete2.png" alt="删除"
												style="margin-left: 8px;" /> </a>
										</c:if> <c:if
											test="${blog.f_manager_name!=me.username&&role=='customer'}">
										 无权限
 														</c:if>
									</td>
								</tr>

							</c:forEach>
						</tbody>
					</table>

				</div>
				<div id='fd'></div>

				<br />

			</div>

			<c:if test="${role=='customer' }">
				<div id="main">

					<div class='blog_main_title'>
						<strong>个人文章列表管理</strong>
						<div id='fd'></div>
					</div>
					<div class="clearfix">
						<div class="right"
							style="margin-bottom: 15px; margin-right: 30px;">
							<form action="${ctx }/blog/blog.action" method="get"
								style="height: 23px;">
								<input class="text" id="query" name="q_articleName"
									placeholder="请输入标题关键字....." title="请输入标题关键字....."
									style="width: 150px; height: 20px;" type="text" /> <input
									type="hidden" value="${me.id}" name="blogerId" /> <input
									class="submit" type="submit" name="method:articleSearch"
									value="搜索" />
							</form>
						</div>
					</div>
				<div id="content-body">
					<c:set var="pagination" value="${articlePagination}" />
					<table cellspacing="0" cellpadding="2" border="0" class="results"
						id="resultstable" width="100%">
						<thead>
							<tr class="group_row">
								<td colspan="100" style="border-top: 1px solid #CCCCCC;"><c:set
										var="searchMethod" value="manageArticles" /> <%@ include
										file="/common/pagination_new.jsp"%></td>
							</tr>
							<tr id="headingrow">
								<th style="border-left: 0" nowrap="nowrap">序号</th>
								<th class="col_1" nowrap="nowrap" id="summaryheading"
									width="130px"><a href="#" style="text-decoration: none">博文标题</a></th>
								<th class="col_0" nowrap="nowrap"><a href="#"
									style="text-decoration: none">所属博客</a></th>
								<th class="col_2" nowrap="nowrap"><a href="#"
									style="text-decoration: none">发表时间</a></th>
								<th class="col_3" nowrap="nowrap"><a href="#"
									style="text-decoration: none">分类标签 </a></th>
								<th class="col_3" nowrap="nowrap"><a href="#"
									style="text-decoration: none">浏览数</a></th>
								<th class="col_3" nowrap="nowrap"><a href="#"
									style="text-decoration: none">回复数</a></th>
								<th nowrap="nowrap" style="width: 50px;"><a
									href="#columnprefs" style="text-decoration: none">管理</a></th>
							</tr>
						</thead>
						<tbody class="border">

								<c:forEach var="myarticle" items="${articlePagination.items}"
									varStatus="status">
									<tr class="ifOpened" id="newModule${myarticle.id}">
										<td class="vt" nowrap="nowrap">
											${articlePagination.startIndex+status.index+1 }</td>
										<hql:queryForUnique
											hql="from Blog where id=${myarticle.blogId}" id="blog" />

										<td class="vt id col_1" width="130px"><a
											href="${ctx }/msg/blog.action?method:article&articleId=${myarticle.id }">
												<yn:cleanHtml str="${myarticle.title}"
													id="articleTextNoHtml" /> <yn:shortIt len="15"
													str="${articleTextNoHtml}" id="articleTextTitle" />
												${articleTextTitle} </a>
										</td>
										<td class="vt id col_0" nowrap="nowrap"
											title="${blog.blogName}"><a
											href="${ctx }/blog/blog.action?method:blog&blogId=${blog.id }">
												${blog.blogName} </a>
										</td>
										<td class="vt id col_2" nowrap="nowrap"><a
											class="yj-message-blog-time"
											title="<fmt:formatDate value="${myarticle.creationDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
											href="javascript://"> <fmt:formatDate
													value="${myarticle.creationDate}"
													pattern="yyyy-MM-dd HH:mm:ss" />
										</a>
										</td>
										<td class="vt col_3">${myarticle.tags }</td>
										<td class="vt col_4"><c:if
												test="${myarticle.click ==null}">0</c:if>${myarticle.click }</td>
										<nativeSql:sqlQueryForUnique
											sql="select count(*) as RECNT from t_article_comment where f_article_id=${myarticle.id} and f_parent_comment_id is null"
											id="replyCount" />
										<td class="vt col_5">${replyCount['RECNT']}</td>
										<td class="vt col_3" align="right"><a
											href="${ctx }/blog/blog.action?method:articleEditForm&articleId=${myarticle.id}"
											title="编辑"> <span class="icon_edit"></span>
										</a> <a href="javascript://" class="gdeleteModule${myarticle.id}">
												<img alt="删除" src="${ctx }/img/delete2.png"
												style="margin-left: 8px" alt="删除" /> </a>
										</td>
									</tr>

								</c:forEach>
							</tbody>
						</table>

					</div>
					<div id='fd'></div>

					<br />

				</div>
			</c:if>


		</div>
		<div id='column-right'><%@ include
				file="/common/right_knowledge.jsp"%></div>
	</div>


	<!-- 提醒框 -->
	<div id="dialog-confirm" title="提醒框" style="display: none;">
		<p style="line-height: 16px; margin: 0 0 1.5em;">
			<span class="ui-icon ui-icon-alert"
				style="float: left; margin: 0 7px 20px 0;"></span> &nbsp;&nbsp;
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;确定删除？YES|NO
		</p>
	</div>

	<div id="yj-inline-icon x-grey-icon yj-closeFlash"
		style="left: 351.5px; display: none;"
		class="yj-alert yj-notice zindex-t4">
		<span class="alert-icon flash-notice-icon"></span>
		<p>
			<a href="javascript://"
				class="yj-inline-icon x-grey-icon yj-closeFlash">x</a>The message
			has been bookmarked.
		</p>
	</div>
	<!-- 悬浮框显示-->
	<div id="face_show" style="width: 288px; display: none;"
		class="yj-tooltip yj-tooltip-under-header-bar yj-hovercard yj-balloon yj-bottom">
	</div>
	<div id="profileWindow_show"
		style="left: 331px; top: 1032px; display: none;"
		class="yj-tooltip yj-tooltip-under-header-bar yj-hovercard yj-balloon yj-bottom">
	</div>
	<%@ include file="/common/footer.jsp"%>
	<%
		} catch (Exception e) {
			e.printStackTrace();
		}
	%>
</body>
</html>
